package components.scenes;

import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.imageio.ImageIO;

import maps.FoodAdder;
import maps.GcAdder;
import maps.GhostRespawnAdder;
import maps.MapParser;
import maps.PacmanSpawnAdder;
import maps.PathAdder;
import maps.SuperFoodAdder;
import maps.WallAdder;

import components.ghost.Ghost;
import components.ghost.SillyGhost;
import components.pacman.Pacman;

public class TestScene extends MainGameScene {

	private MapParser mapParser;
	
	public TestScene(){
		
		this.initParser();
		this.parseMap();
		
		Pacman p = new Pacman();
		this.addWalker(p, 1, 1);
		this.respawnWalker(p, this.getPacmanSpawn());
		Ghost ghost = new Ghost(p);
		this.addGhost(ghost, this.getGhostSpawn().getX(), this.getGhostSpawn().getY());
		this.respawnWalker(ghost, this.getGhostSpawn());
		
		Ghost sghost = new SillyGhost(p);
		this.addGhost(sghost, this.getGhostSpawn().getX(), this.getGhostSpawn().getY());
		this.respawnWalker(sghost, this.getGhostSpawn());
	}


	private void parseMap() {
		BufferedImage map = MapParser.getImage("/maps/map3.PNG");
		this.mapParser.parseImage(map, this);
				
	}

	private void initParser() {
		Map<Integer, GcAdder> map = new HashMap();
		map.put(0, new WallAdder());
		map.put(1, new PathAdder());
		map.put(2, new FoodAdder());
		map.put(3, new PacmanSpawnAdder());
		map.put(4, new GhostRespawnAdder());
		map.put(5, new SuperFoodAdder());
		
		BufferedImage colorcfg;
		try {
			colorcfg = ImageIO.read(this.getClass().getResource("/colors/colorscfg.PNG"));
			mapParser = new MapParser(colorcfg, map);
		} catch (IOException e) {
			e.printStackTrace();
		}
		

	}
	

}
